package com.ticket.service.impl;

import com.ticket.dao.MovieDao;
import com.ticket.dao.StageDao;
import com.ticket.entity.*;
import com.ticket.service.MovieService;
import com.ticket.util.MybatisUtil;
import com.ticket.util.Page;
import org.apache.ibatis.session.SqlSession;

import java.util.List;


/**
 * @author 全谢民
 * @version 8.0
 * @description: TODO
 * @date 2023/10/216:37
 */
public class MovieServiceImpl implements MovieService {
    static MovieDao md;

    static {
        SqlSession sqlSession = MybatisUtil.getSqlSession();
        md = sqlSession.getMapper(MovieDao.class);
    }

    /*
     * @author 全谢民
     * @description TODO 前端首页电影根据电影评分降序
     * @date 2023/10/12 19:23
     */
    @Override
    public List<HomePage> selHomeMovieList() {
        List<HomePage> homePageMovieList = md.selHomeMovieList();
        return homePageMovieList;
    }

    /*
     * @author 全谢民
     * @description TODO 前端搜索页面查询电影
     * @date 2023/10/14 16:50
     */
    @Override
    public List<Search> selSearchMovieList(Search search){
        List<Search> searchMovieList = md.selSearchMovieList(search);
        return searchMovieList;
    }


    /*
     * @author 全谢民
     * @description TODO 查询用户收藏列表的电影收藏
     * @date 2023/10/9 19:59
     */
    @Override
    public List<MovieCollect> selMovieCollectList(int userId) {
        List<MovieCollect> movieList = md.selMovieCollectList(userId);
        return movieList;
    }



    //    MovieDao md = new MovieDaoImpl();
    /*
     * @author 全谢民
     * @description TODO 前端首页获取评分前1/2-7的电影
     * @date 2023/10/2 17:51
     */
    @Override
    public Page<Movie> selMovie(Page page) {
        return null;
    }

    /*
     * @author 全谢民
     * @description TODO 分类页面电影查询
     * @date 2023/10/3 14:09
     */
    @Override
    public Page<Movie> movieClassification(Page<Movie> page, Movie movieAddress) {
//        return md.movieClassification(page,movieAddress);
        return null;
    }

    /**
     * @description TODO 后端电影分页查询
     * @author XuGuoZhi
     * @date 2023/10/13 18:39
      * @param moviePage
     * @param movieName
     * @return com.ticket.util.Page<com.ticket.entity.Movie>
     */
    @Override
    public Page<Movie> moviePageAndMovieNameSel(Page<Movie> moviePage, String movieName) {
        List<Movie> movieList= md.moviePageAndMovieNameSel(moviePage,movieName);
        int movieCount=md.moviePageCountSel(movieName);
        moviePage.setTotalCount(movieCount);
        moviePage.setDataList(movieList);
        return moviePage;
    }
    /**
     * @description TODO 影院后端电影分页查询
     * @author Lixin
     * @date 2023/10/13 18:39
     * @param moviePage
     * @param movie
     * @return com.ticket.util.Page<com.ticket.entity.Movie>
     */
    @Override
    public Page<Movie> selMoviePageMovieName(Page<Movie> moviePage,Movie movie) {
        List<Movie> movieList= md.selMoviePageMovieName(moviePage,movie);
        int movieCount=md.selMoviePageCount(movie);
        moviePage.setTotalCount(movieCount);
        moviePage.setDataList(movieList);
        return moviePage;
    }
}
